package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.GoodsBean;
import com.project.service.IGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("goods")
@Api(tags = "商品库存控制层")
public class GoodsController {
    @Autowired
    private IGoodsService goodsService;
    @GetMapping("cutByItem")
    @ApiOperation("条件分页查询商品")
    public IPage<GoodsBean> cutByItem(Integer pageNO, String name, Integer startNum, Integer endNum, boolean price, String type) {
        return goodsService.cutByItem(pageNO,name,startNum,endNum,price,type);
    }

    @GetMapping("findById")
    @ApiOperation("通过商品id查询商品")
    public GoodsBean findById(String id) {
        return goodsService.findById(id);
    }

    @PutMapping("updatePrice")
    @ApiOperation("修改建议销售价")
    public String updatePrice(String id, Integer sellPrice) {
        goodsService.updatePrice(id,sellPrice);
        return "ok";
    }

}
